<meta name="csrf-token" content="{{ csrf_token() }}">
<link rel="stylesheet" href="{{ URL::asset('rankinglist/css/eject.css') }}"/>
<style>
/*比赛排名*/
ul li{
    list-style: none;
}
 .l_icon {
	background:  url("{{ URL::asset('/rankinglist/images/polygon.png') }}") no-repeat;
	width: 1170px;
	height: 52px;
	font-size: 24px;
	line-height: 52px;
	color: #fff;
	padding-left: 30px;
}
.l_search {
	position: absolute;
	right: 0;
	top: 5px;
       
}
.l_search input {
	float: left;
	padding-left: 10px;
}
.l_search input[type=text] {
	width: 216px;
	height: 34px;
	border: 1px solid #dcab61;
	border-radius: 4px;
}
.l_search input[type=button] {
	width: 90px;
	height: 34px;
	background-color: #f13652;
	border-radius: 4px;
	margin-left: 13px;
	font-size: 14px;
	border: 0 none;
	color: #fff;
}
/*排名列表*/
.l_list {
	overflow: hidden;
    width: 1200px;
}
 .l_list .l_title {
	height: 48px;
	line-height: 48px;
	background-color: #f2d2a6;
    margin:0 auto;
     padding-left: 0px;
}
.l_list .l_title li {
	float: left;
	width: 14%;
	text-align: center;
	border-bottom: 1px dashed #e3e3d6;
}
.l_list .l_main {
    padding-left: 0px;
    background-color: #fdfef4;
    margin: 0px;
}
.l_list .l_main li {
	border: 1px dashed #EAEADD;
	border-top: none;
    height: 66px;
    cursor: pointer;
}
.l_list .l_main li div{
	float: left;
	width: 14%;
	height: 66px;
	line-height: 66px;
	text-align: center;
	font-size: 14px;
	color: #494949;
}
.l_list .l_main li div.photo {
	width: 44px;
	height: 44px;
	border-radius: 50%;
	vertical-align: middle;
	margin-top: 14px;
	position: relative;
	left: 20px;
    top: -6px;
}
.l_list .l_main li div.photo img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
}
.l_list .l_main li div:nth-child(3){
	color: #f73353;
}
/*分页按钮*/
.jpage {
    float: right;
    margin-right: 20px;
    margin-top: 22px;
}
.jpage > .jpage_div1 > div,
.jpage > .jpage_div1 > a,
.jpage > .jpage_div1 > span{
    float: left;
    line-height: 30px;
}
.jpage > .jpage_div1 > a {
    display: block;
    width: 70px;
    height: 30px;
    background-color: #f13652;
    color: #fff;
    border-radius: 2px;
    text-align: center;
    line-height: 30px;
    margin: 0 16px;
    text-decoration: none;
    font-size: 14px;
}
.jpage > .jpage_div1 > div:first-child {
    margin-right: 5px;
}
.jpage > .jpage_div1 > div:last-child {
    margin-left: 5px;
}


</style>
<script src="{{ URL::asset('public_js/jquery-3.2.1.min.js') }}"></script>
<script src="{{ URL::asset('public_js/jquery.nicescroll.min.js') }}"></script>
<script src="{{ URL::asset('public_js/src/Highcharts-5.0.10/code/highcharts.js') }}"></script>
<script src="{{ URL::asset('public_js/src/Highcharts-5.0.10/code/modules/exporting.js') }}"></script>
<script src="{{ URL::asset('public_js/src/Highcharts-5.0.10/code/highcharts-more.js') }}"></script>
<script src="{{ URL::asset('public_js/src/Highcharts-5.0.10/code/modules/solid-gauge.js') }}"></script>
<script>
    function gotopage(page,pagetype){
        var searchname = $('#searchname').val()
        if(pagetype == 0) {
            var url = "?page="+(page)+"&type="+pagetype+"&searchname="+searchname;
        }else{
            var url = "?page="+(page+1)+"&type="+pagetype+"&searchname="+searchname;
        }
        url = '/gameranking'+url;
        $(window.parent.document).find("#gameRank").attr("src",url);
    }
</script>
<div class="l_icon">
    比赛排名
</div>
<div class="l_search">
    <input type="text" id="searchname" class="sear" value="{{$searchname}}" placeholder="请输入用户名">
    <!--  <input type="text" onblur="if(this.value == '')this.value='请输入用户名';" onclick="if(this.value == '请输入用户名')this.value='';value="{{$searchname}}" placeholder="请输入用户名">-->
    <input type="button" value="搜索" class="btn" onclick="gotopage(0,1)">
</div>

<div class="l_list">
    <ul class="l_title">
        <li>本周排名</li>
        <li>选手</li>
        <li>周收益点位</li>
        <li>周单均盈利</li>
        <li>周胜率</li>
        <li>周策略数量</li>
        {{--<li>总盈利点位</li>--}}
        <li>操作</li>
    </ul>
    @if($dataarr)
        <ul class="l_main clearfix">
            @foreach($dataarr as $key=>$val)
                <li class="weekBang_lis" id="weekBang_lis" onclick="weekRank({{(($page-1)*10)+$key+1}},{{$val->id}},event)">
                    <div>{{(($page-1)*10)+$key+1}}</div>
                    <div>
                        <div class="photo">
                            <img src="@if($val->photo) {{$val->photo}} @else{{ URL::asset('/rankinglist/images/user_tx.png') }} @endif" alt="{{$val->id}}" title="{{$val->id}}">
                            @if($val->authstatus == 2)
                                <img class='user_vip' src="{{ URL::asset('rankinglist/images/user_vip.png')}}" alt="" style="width:18px;height:18px;z-index: 2;position: absolute;left: 33px;top: 26px" >
                            @endif
                        </div>
                        <span>{{$val->username}}</span>
                    </div>
                    <div>{{round($val->week_final_point,2)}}</div>
                    <div>{{round($val->single_final_point,2)}}</div>
                    <div>{{round($val->winrate,2)}}%</div>
                    <div>{{$val->ordernum}}</div>
                     {{--<div>{{round($val->total_final_point,2)}}</div> --}}
                    <div><input type="button" value="订阅" class="btn" onclick="subfollow(this)"  status="3" direction="3" style="margin-top:15px;">
                        <style>
                            .btn {
                                width: 90px;
                                height: 34px;
                                background-color: #f13652;
                                border-radius: 4px;
                                margin-left: 13px;
                                font-size: 14px;
                                border: 0 none;
                                color: #fff;
                            }
                        </style>
                    </div>
                </li>
            @endforeach
        </ul>
    @endif
    @include('bangdan.eject')
<!-- 周榜分析师详情界面开始lang -->
    <!-- <div class="l_weekBang" id="l_weekBang" style="z-index:15;">
    </div> -->
    <!-- 周榜分析师详情界面结束lang -->
    @if($allnum != 0)
        <div class="pagebox">
        <div class="jpage clearfix">
            <div class="jpage_div1" id="pagefollow">
                @if($page == 1 || $page == 0)
                    <a href="javascript:void(0)"target="gameRank" style="background-color:#c2c4c9">上一页</a>
                @else
                    <a href="javascript:void(0)" onclick="gotopage({{$page}},0)"  target="gameRank" style="background-color:#f13652">上一页</a>
                @endif
                <span>第<span style="color:#f73353;">{{ $page }}</span>页</span>

                @if($page == $allpage)
                    <a href="javascript:void(0)"  target="gameRank" style="background-color:#c2c4c9">下一页</a>
                @else
                    <a href="#"  onclick="gotopage({{$page}},1)" target="gameRank" style="background-color:#f13652">下一页</a>
                @endif
                <div>共 {{ $allpage }} 页</div>
            </div>
        </div>
        </div>
    @endif

</div>
<script>
var aid       = 0;
var analyst_username = '';
var status    = 3;//是否订阅
var direction = 3;//订阅方向

// 点击按钮，关闭层
$(".close").click(function(){
    $(document).unbind("scroll.unable");
    $('#mask').css({'display':'none'});
    $('#popUp').css({'display':'none'});
})
// 遮挡层
function l_Mask(){
    var div_mask=$('#mask');
    var width=document.body.scrollWidth+'px';
    var height=document.body.scrollHeight+'px';
    div_mask.css({'width':width,'height':height,'display':'block'});
    div_mask.show();
}
// 显示
function showCeng(){
    var div_mask=$('#mask');
    var width=document.body.scrollWidth+'px';
    var height=document.body.scrollHeight+'px';
    div_mask.css({'width':width,'height':height,'display':'block'});
    $('#mask').show();
    $("#tanCeng").show();
}
// 隐藏
function hideCeng(){
    var div_mask=$('#mask');
    var width=document.body.scrollWidth+'px';
    var height=document.body.scrollHeight+'px';
    div_mask.css({'width':width,'height':height,'display':'block'});
    $('#mask').hide();
    $("#tanCeng").hide();
}
var doinfourl = '{{url("/showinfo")}}';
// 周榜分析师详情界面开始lang
function weekRank(ranking,userid,event){
        window.parent.l_Mask();
        $(window.parent.document).find("#l_weekBang").show();
        // 禁用滚动条
        // var top = window.parent.document.body.scrollTop;
        // $(window.parent.document).on('scroll.unable',function (e) {
        //     $(window.parent.document).scrollTop(top);
        // })

        if(event.stopPropagation){
            event.stopPropagation();
        }else{
            window.event.cancelBubble();
        }
         $.ajax({
             url: doinfourl,
             type: "POST",
             data:  {userid:userid},
             headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') },
             dataType:'json',
             async:false,
             success: function (data) {
                 if(data.status == 1){
                     layer.msg(data.msg,{time:1000});
                 }else{
                     var str='';
                     str+='<div class="weekBang_close" onclick="weekBangclose()"><img src="{{ URL::asset('/rankinglist/images/close2.png') }}" alt=""></div>';
                     str+='<div id="l_scroll" class="l_scroll"><div class="l_bar" id="l_bar"></div></div>';
                     str+='<div class="bang_left">';
                     str+='<div class="bang_pic"><div id="weekBang_chart" style="width:157px;height:70px;"></div></div>';
                     str+='<div class="bang_term"><span>第</span><span style="font-size:48px;color: #20222c;margin: 0 8px;">'+ranking+'</span><span>名</span></div>';
                     str+='<div class="bang_line"></div>';
                     str+='<div class="bang_muqian">目前名次</div></div>';
                     str+='<div class="bang_right" id="bang_right" class="bang_right"><ul id="content">';
                     str += '<li class="bang_title"><div>单号</div><div>品种</div><div>方向</div><div>入场价格</div><div>平仓价格</div><div>平仓时间</div><div>最终盈亏</div></li>';
                     for(var i=0;i<data.trendpointobj.length;i++) {
                         str += '<li>';
                         str += '<div>'+data.trendpointobj[i].tradeid+'</div>';
                         str += '<div>'+data.trendpointobj[i].typename+'</div><div>';
                         if(data.trendpointobj[i].buy_status == 1){
                             str += '卖出';
                         }else{
                             str += '买入';
                         }
                         str += '</div><div>'+data.trendpointobj[i].begin_point+'</div>';
                         str += '<div>'+data.trendpointobj[i].end_point+'</div>';
                         str += '<div><span>'+UnixToDate(data.trendpointobj[i].end_time,true,'',0)+'</span><span>'+UnixToDate(data.trendpointobj[i].end_time,false,'',1)+'</span></div>';
                         if(data.trendpointobj[i].final_point >0 ){
                             str += '<div style="color:red">'+data.trendpointobj[i].final_point+'</div>';
                         }else{
                             str += '<div style="color:green">'+data.trendpointobj[i].final_point+'</div>';
                         }
                         str += '</li>';
                     }
                     str+='</ul></div>';

                     $(window.parent.document).find('#l_weekBang').html(str);
                     x_chart_point     = data.pointstr.split(',');
                     var x_chart_data  = [];
                     x_chart_point.forEach(function(data,index,arr){
                         x_chart_data.push(+data);
                     });

                     var weekBang_chart=$(window.parent.document).find('#weekBang_chart');
                     weekBangChart(weekBang_chart,x_chart_data);
                 }
             }
         });
        // 弹层滚动条
        $(window.parent.document).ready(function(){
            $(window.parent.document).find(".bang_right").niceScroll({
                cursorborder:"",
                cursorwidth:"10px",
                cursorcolor:"#707883",
                boxzoom:true,
                cursoropacitymin: 1,
                background:"#b2b2b2"
            }); 
        })
      }

    function weekBangChart(id,data){
        return id.highcharts({
            chart: {
                type: "areaspline",
                spacing: [0, 0, 0, 0]
            },
            title: {
                text: null
            },
            colors:['#ffc766'],
            legend: {
                enabled: false
            },
            credits: {
                enabled: false
            },
            exporting: {
                enabled:false
            },
            xAxis: {
                gridLineWidth: 0,
                tickLength: 0,
                labels: {
                    enabled: !1
                },
                title: {
                    text: null
                },
                lineWidth: 0,
                tickInterval: 1,
                lineColor: "#cccccc",
                gridLineColor: "#f0f0f0"
            },
            tooltip: {
                style: {
                    color: "white",
                    padding: "4px"
                },
                borderWidth: 0,
                shadow: !1,
                backgroundColor: "rgba(34,34,34, 0.6)",
                shared: !0,
                formatter: function() {
                    return '<span style="color:' + (this.y >= 0 ? "#00ffa3" : "#ff846b") + '">盈亏点位' + this.y + "</span>"
                }
            },
            yAxis: {
                gridLineWidth: 0,
                tickLength: 0,
                labels: {
                    enabled: !1
                },
                title: {
                    text: null
                },
                tickInterval: 1,
                lineColor: "#cccccc",
                gridLineColor: "#f0f0f0"
            },
            plotOptions: {
                areaspline: {
                    fillColor: {
                        linearGradient: {
                            x1: 0,
                            y1: 0,
                            x2: 0,
                            y2: .8
                        },
                        stops: [
                            [0, "#fcb368"],
                            [1, Highcharts.Color("#fcb368").setOpacity(0).get('rgba')]
                        ]
                    },
                    marker: {
                        radius: 0,
                        fillColor: "white",
                        lineWidth: 0.5,
                        lineColor: "#ff8201"
                    },
                    lineWidth: 0.5,
                    states: {
                        hover: {
                            lineWidth: 0.5
                        }
                    },
                    threshold: null
                },
                series: {
                    lineColor: "#ff8201",
                    point: {}
                },
            },
            series: [{
                name: '',
                data: data
            }]
                     
        })
    }
    
    // 周榜分析师详情界面结束lang
    //时间转换方法
    function UnixToDate(unixTime, isFull, timeZone,type) {
        if (typeof (timeZone) == 'number')
        {
            unixTime = parseInt(unixTime) + parseInt(timeZone) * 60 * 60;
        }
        var time = new Date(unixTime * 1000);
        var ymdhis = "";
        if(type){
            ymdhis += time.getFullYear() + "-";
            ymdhis += (time.getMonth()+1)>9?(time.getMonth()+1)+'-':'0'+(time.getMonth()+1) + "-";
            ymdhis += time.getDate()>9?time.getDate():'0'+time.getDate();
        }
        if (isFull === true)
        {

            ymdhis += " " + time.getHours()>9?time.getHours()+ ":":'0'+time.getHours() + ":";
            ymdhis += time.getMinutes()>9?time.getMinutes()+ ":":'0'+time.getMinutes() + ":";
            ymdhis += time.getSeconds()>9?time.getSeconds():'0'+time.getSeconds();
        }
        return ymdhis;
    }


// 点击订阅按钮，弹出协议层
function subfollow(obj){
    $('#popUp').css('display','block');
    var top = $(document).scrollTop();
    $(document).on('scroll.unable',function (e) {
        $(document).scrollTop(top);
    })
    var islogin = "<?php echo Session('eai')['tel']?>";
    if(!islogin){
        //layer.msg('请先<a href="{{ url('/login') }}">登录</a>！');
        showCeng();
        $('#tanCeng>a>button').hide();
        $("#tanCeng").css({'width':'250px','height':'80px','line-height':'80px'}).html('请先<a href="{{ url('/login') }}" style="cursor:pointer;color:#3b9ce0;font-size: 20px;">登录</a>！');
        return false;
    }
    {{--var infofinish = '{{$infofinish}}';--}}
    if(infofinish == 1){
        var gowanshan = "{{url('/authenticate?id=info')}}";
        $('.popUp').hide();
        showCeng();
        $('#tanCeng>a>button').hide();
        $("#tanCeng>span").css({'margin-top':'2px'}).html("您未完善资料，<a href='"+gowanshan+"' style='cursor:pointer;color:#3b9ce0;'>请完善资料!</a>");
        return false;
    }else{
        aid              = $(obj).attr('analyst_id');
        analyst_username = $(obj).attr('analyst_username');
        status           = $(obj).attr('status');
        direction        = $(obj).attr('direction');
        if(this.innerHTML == "订阅") {
            var cancleBtn=$(".foot_right>input");
            cancleBtn.css({"visibility":"hidden"});
        }
        if(this.innerHTML == "编辑订阅") {
            var thisBtn=this;
        }
        if(status == 1){
            $('#gendancancle').show();
        }else{
            $('#gendancancle').hide();
        }
        $('#mask').css({'display':'block'});
        $('#popUp').css({'display':'block'})
    }
}
</script>
